import os
import re
import time
from datetime import datetime

db_namne = 'automation_test_platform' # 数据库名称
project_num = '视图平台'

#项目路径
PROJECT_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

basic_path = os.path.join(PROJECT_PATH, 'Basic')

Conf_path=os.path.join(PROJECT_PATH, 'Conf')
FindElement_path=os.path.join(PROJECT_PATH, 'FindElement')
UiniTest_path=os.path.join(PROJECT_PATH, 'UiniTest')

confini_path= os.path.join(PROJECT_PATH, 'Conf', "config.ini")
log_path=os.path.join(PROJECT_PATH, 'Logs')
code_path=os.path.join(PROJECT_PATH, 'Logs',"getcode.jpg")
# datatime=time.strftime('%Y-%m-%d %H.%M.%S.%f', time.localtime(time.time()))
datatime = datetime.now().strftime('%Y-%m-%d %H.%M.%S.%f')[:-3]
# print(datetime)
daytime=time.strftime('%Y-%m-%d', time.localtime(time.time()))
filename = os.path.join(Conf_path, "selenium_case.xlsx")
sheetname = project_num
background_path = os.path.join(Conf_path, "background.jpg")

# print('项目路径：%s'%PROJECT_PATH)

var_dict = {}  #全局变量
table_dict = {} #表格全局变量
list_table =[] #列表全局变量

# 在字符串指定位置插入字符
# str_origin：源字符串  pos：插入位置  str_add：待插入的字符串
#
def str_insert(str_origin, pos, str_add):
    str_list = list(str_origin)    # 字符串转list
    str_list.insert(pos, str_add)  # 在指定位置插入字符串
    str_out = ''.join(str_list)    # 空字符连接
    return  str_out

def get_dictpath():
    path_dict = {"package_path": os.getcwd(),
                 "basic_path": os.path.join(os.getcwd(), 'Basic'),
                 "Conf_path": os.path.join(os.getcwd(), 'Conf'),
                 "confini_path": os.path.join(os.getcwd(), 'Conf', "config.ini"),
                 "FindElement_path": os.path.join(os.getcwd(), 'FindElement'),
                 "UiniTest_path": os.path.join(os.getcwd(), 'UiniTest'),
                 "log_path": os.path.join(os.getcwd(), 'Logs'),
                 "code_path": os.path.join(os.getcwd(), 'Logs', "getcode.jpg"),
                 "datatime": datetime.now().strftime('%Y-%m-%d %H.%M.%S.%f')[:-3],
                 "daytime": time.strftime('%Y-%m-%d', time.localtime(time.time()))
                 }
    if not os.path.exists(os.path.join(os.getcwd(), 'Logs')):
        os.makedirs(os.path.join(os.getcwd(), 'Logs'))
    return path_dict



